/*
 * stdout_redir.c
 * 	将标准输出重定向到串口1
 *
 *  Created on: Apr 1, 2021
 *      Author: soliber
 */

#include "usart.h"

#ifdef RTE_Compiler_IO_STDOUT
//for MDK-ARM
#define PUTCHAR_PROTOTYPE int stdout_putchar(int ch)
#else
//for STM32CubeIDE
#define PUTCHAR_PROTOTYPE int __io_putchar(int ch)
#endif


/**
  Put a character to the stdout

  \param[in]   ch  Character to output
  \return          The character written, or -1 on write error.
*/
PUTCHAR_PROTOTYPE
{
	if(HAL_OK==HAL_UART_Transmit(&huart2,(uint8_t*)&ch,1,HAL_MAX_DELAY))
		return ch;
	else
		return -1;
}
